//
//  WFDGuideCell.m
//  谷居
//
//  Created by dllo on 16/7/6.
//  Copyright © 2016年 刘万方. All rights reserved.
//

#import "WFDGuideCell.h"
#import "Masonry.h"
#import "WFHandleURL.h"
#import "UIImageView+AFNetworking.h"
@implementation WFDGuideCell

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createCell];
    }
    return self;
}


- (void)createCell {
    _titleLabel = [[WFLabel alloc] init];
    [self.contentView addSubview:_titleLabel];
    [_titleLabel release];
    
    
    _rightImageView = [[WFImageView alloc] init];
    [self.contentView addSubview:_rightImageView];
    [_rightImageView release];
    
    _bottomLabel = [[WFLabel alloc] init];
    [self.contentView addSubview:_bottomLabel];
    [_bottomLabel release];
    
    
    _likeLabel = [[WFLabel alloc] init];
    [self.contentView addSubview:_likeLabel];
    [_likeLabel release];
    
    
    _likeImageView = [[WFImageView alloc] init];
    [self.contentView addSubview:_likeImageView];
    [_likeImageView release];
    
    
    _commentLabel = [[WFLabel alloc] init];
    [self.contentView addSubview:_commentLabel];
    [_commentLabel release];
    
    _commentImageView = [[WFImageView alloc] init];
    [self.contentView addSubview:_commentImageView];
    [_commentImageView release];
    
    
    
}


- (void)layoutSubviews {
    [super layoutSubviews];
    [_rightImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.right.bottom.equalTo(self.contentView).offset(-5);
        make.top.equalTo(self.contentView).offset(5);
        make.width.equalTo(_rightImageView.mas_height);
    }];
    
    NSString *url = [WFHandleURL getPicURL:self.model.covorPhotoId];
    NSLog(@"url : %@", url);
    [_rightImageView setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"图片加载.png"]];
    [_titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.contentView).offset(10);
        make.top.equalTo(self.contentView).offset(20);
        make.width.greaterThanOrEqualTo(@60);
        make.height.greaterThanOrEqualTo(@20);
    }];
    _titleLabel.text = self.model.title;
    [_titleLabel sizeToFit];
    
    
    [_bottomLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(10);
        make.bottom.equalTo(self.contentView).offset(-10);
        make.width.greaterThanOrEqualTo(@20);
        make.height.mas_equalTo(@20);
    
    }];
    _bottomLabel.text = self.model.categoryName;
    _bottomLabel.font = [UIFont systemFontOfSize:14];
    [_bottomLabel sizeToFit];
    
    [_likeImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(_bottomLabel.mas_right).offset(10);
        make.bottom.equalTo(self.contentView).offset(-10);
        make.size.mas_equalTo(CGSizeMake(16, 16));
        
    }];
    _likeImageView.image = [UIImage imageNamed:@"喜欢1.png"];
    
    [_likeLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(_likeImageView.mas_right).offset(5);
        make.centerY.equalTo(_bottomLabel.mas_centerY);
        make.width.greaterThanOrEqualTo(@10);
        make.height.mas_equalTo(20);
        
    }];
    _likeLabel.text = [NSString stringWithFormat:@"%ld", self.model.likeCount];
    _likeLabel.font = [UIFont systemFontOfSize:14];
    [_likeLabel sizeToFit];
    
    
    [_commentImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(_likeLabel.mas_right).offset(20);
        make.bottom.equalTo(self.contentView).offset(-10);
        make.size.mas_equalTo(CGSizeMake(16, 16));
    }];
    _commentImageView.image = [UIImage imageNamed:@"评论.png"];
    [_commentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(_commentImageView.mas_right).offset(10);
        make.centerY.equalTo(_bottomLabel.mas_centerY);
        make.height.mas_equalTo(20);
        make.width.greaterThanOrEqualTo(@10);
    }];
    _commentLabel.text = [NSString stringWithFormat:@"%ld", self.model.commentConut];
    _commentLabel.font = [UIFont systemFontOfSize:14];
    [_commentLabel sizeToFit];
    
    
    
}



@end
